package com.example.seataAccount.controller;

import com.example.seataAccount.common.response.ObjectResponse;
import com.example.seataAccount.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("account")
@Slf4j
public class AccountController {

    private final AccountService accountService;

    public AccountController(AccountService accountService) {
        this.accountService = accountService;
    }

    /**
     * 扣减账户金额接口
     *
     * @param userId     用户ID
     * @param orderMoney 订单金额
     */
    @PostMapping
    @ResponseBody
    public ObjectResponse<Object> decreaseAccount(@RequestParam String userId, @RequestParam Double orderMoney) {
        log.info("userId参数的值是：{}, orderMoney参数的值是：{}", userId, orderMoney);
        return accountService.decreaseAccount(userId, orderMoney);
    }
}
